home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / SAS-C / sc655pch / mount / test.c < prev   
Encoding:
C/C++ Source or Header  |  1995-01-11  |  1.3 KB  |  51 lines

  1. #include <dos/dosextens.h>
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include "mount.h"
  5. #include <stdio.h>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.    struct DeviceList *dl;
  10.    struct MsgPort *port, *replyport;
  11.    struct Message *msg;
  12.    struct DosPacket *pkt;
  13.  
  14.    if(argc<2)
  15.    {
  16.       fprintf(stderr, "USAGE: %s <volumename>\n", argv[0] ? argv[0] : "");
  17.       return(20);
  18.    }
  19.    if(port = CreatePort(0L, 0L))
  20.    {
  21.       if(dl = Mount(argv[1], port))
  22.       {
  23.          printf("Waiting for packets.  Hit CTRL-C to exit.\n");
  24.          while(1)
  25.          {
  26.             while(msg = GetMsg(port))
  27.             {
  28.                pkt = (struct DosPacket *)msg->mn_Node.ln_Name;
  29.                printf("DOS packet type %d received\n", pkt->dp_Type);
  30.  
  31.                /* Flush the packet back to its origin with an error */
  32.                pkt->dp_Res1 = DOSFALSE;
  33.                pkt->dp_Res2 = ERROR_ACTION_NOT_KNOWN;
  34.                replyport = pkt->dp_Port;
  35.                pkt->dp_Port = port;
  36.                PutMsg(replyport, pkt->dp_Link);
  37.             }
  38.             if(Wait( (1<<port->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
  39.                break;
  40.          }
  41.          DisMount(dl);
  42.       }
  43.       else
  44.          fprintf(stderr, "Can't mount volume \"%s\"\n", argv[1]);
  45.       DeletePort(port);
  46.    }
  47.    else
  48.       fprintf(stderr, "Can't create port\n");
  49.    return 0;
  50. }
  51.